import 'package:flutter/material.dart';
import 'package:flutter_blank/common/assets.dart';
import 'package:flutter_blank/common/widgets.dart';
import 'package:flutter_blank/pages/login.dart';

class WelcomePage extends StatelessWidget {
  const WelcomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(body: Center(child: _buildView(context)));
  }

  void onToLogin(context) {
    Navigator.push(
      context,
      MaterialPageRoute(builder: (context) => const LoginPage()),
    );
  }

  Widget _buildView(context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        // 标题
        _buildText("Browse & Order All Products at Any Time"),
        // 间距
        const SizedBox(height: 70),
        // 图片
        Image.asset(
          AssetsImages.welcomePng,
          height: 409,
          width: double.infinity,
          fit: BoxFit.none,
        ),
        // 按钮
        _buildBtns(context),
      ],
    );
  }

  Padding _buildText(String text) {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 38),
      child: Text(
        text,
        textAlign: TextAlign.center,
        style: TextStyle(
          fontSize: 20,
          fontWeight: FontWeight.bold,
          color: Color(0xff2B2A2A),
        ),
      ),
    );
  }

  Widget _buildBtns(context) {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 24),
      child: Row(
        children: [
          // skip
          TextButton(
            onPressed: () => onToLogin(context),
            child: const Text(
              "Skip",
              style: TextStyle(
                fontSize: 15,
                fontWeight: FontWeight.w300,
                color: Color(0xff2B2A2A),
              ),
            ),
          ),
          // 撑开
          const Expanded(child: SizedBox()),
          // get started
          ButtonWidget(
            text: "Get Started",
            height: 42,
            widget: 140,
            radius: 32,
            onPressed: () => onToLogin(context),
          ),
        ],
      ),
    );
  }
}
